package com.itheima.web.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/axiosServlet")
public class AxiosServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        System.out.println("get......");
        //.接收请求参数
        String username = request.getParameter("username");
        System.out.println(username);

        //2.响应数据
        response.getWriter().write("Hello Axios~");
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("post......");
        this.doGet(request, response);
    }
}
/*弹幕说
异步的本质就是多线程
尽量都用异步,如果你有需要同步就用await,不然项目大了会搞死的
异步处理是页面内容发生变化 并不是页面变化,就等于一个网页里的小组件变了,容器还是这个容器
异步慢了更难受，也不提示，也没反应，也不知道请求发出去没有
thymeleaf是混合开发
 */


// F12ajaxServlet的Type是xhr（xmlhttprequest）就是异步类型